/*!
 * \file frthrift_json_bool_and_str_report.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2017/03/07
 *
 */

#include <CUnit/Basic.h>
#include <stdlib.h>
#include <json-c/json.h>

#include "frcomm.h"
#include "frmem.h"
#include "conntrack.h"
#include "frct_comm.h"
#include "frbyte_buffer.h"
#include "frreport_comm.h"
#include "../../../src/module/json/config.h"
#include "../../../src/module/json/json_data_analyze.h"
#include "../../../src/module/json/json_comm.h"
#include "../../../src/module/json/json_core.h"

#include "apmtest_cunit.h"
#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

extern int frthrift_json_bool_and_str_report(Frreport_body_data *p_st_body_data, char *p_name, struct json_object *p_st_value);

static void case1(void)
{
    int i_ret = 0;
    Frreport_body_data *p_st_body_data = NULL;

    i_ret = frthrift_json_bool_and_str_report(p_st_body_data, NULL, NULL);

    CU_ASSERT_EQUAL(i_ret, FR_FAIL);

}

static void case2(void)
{
    int i_ret = 0;
    Frreport_body_data *p_st_body_data = NULL;
    Conntrack *p_st_conn = NULL;
    i_ret = apmtest_create_ct(&p_st_conn, json_session_destroy, (char *)"192.168.0.1", (char *)"192.168.0.35", 9090, 5672);
    p_st_body_data = frreport_body_new_l7 (p_st_conn);
    struct json_object *p_st_value = NULL;


    p_st_value = json_object_new_string((char *)"sayHello");

    i_ret = frthrift_json_bool_and_str_report(p_st_body_data, (char *)"str", p_st_value);

    CU_ASSERT_EQUAL(i_ret, FR_SUCC);
    json_object_put(p_st_value);
    frreport_body_free(&p_st_body_data);
    apmtest_destroy_ct(&p_st_conn);

    return;
}



int add_suite_frthrift_json_bool_and_str_report(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" frthrift_json_bool_and_str_report()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", case1);
    CU_add_test(pSuite, "case2", case2);


    return FR_SUCC;

}